home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / MacTCP Library 1.1 / Library / LowLevel ƒ / Source ƒ / TCP.c < prev    next >
Encoding:
Text File  |  1995-12-04  |  6.1 KB  |  196 lines  |  [TEXT/SPM ]

  1. pb* pb,Boolean async){
  2.     
  3.     if (pb==(TCPiopb*)0)
  4.         return tcpNilPB;
  5.     
  6.     if (pb->ioCRefNum==0)
  7.         return tcpNilRefNum;
  8.     
  9.     if (pb->tcpStream==(StreamPtr)0)
  10.         return tcpNilStream;
  11.     
  12.     pb->csCode=TCPNoCopyRcv;
  13.     
  14.     return SyncAsync((ParmBlkPtr)pb,async);
  15. }
  16.  
  17. /*
  18.     TCP_RcvBfrReturn
  19.     
  20.     Returns to the TCP driver a set of receive buffers that a successfully completed TCP_NoCopyRcv command
  21.     passes directly to the user.  The RDS must be identical to the RDS given to the user when the TCP_NoCopyRcv
  22.     command is completed.  TCP_BfrReturn returns an error if you attempt to return a set of buffers more
  23.     than once.
  24. */
  25. OSErr TCP_RcvBfrReturn(TCPiopb* pb,Boolean async){
  26.     
  27.     if (pb==(TCPiopb*)0)
  28.         return tcpNilPB;
  29.     
  30.     if (pb->ioCRefNum==0)
  31.         return tcpNilRefNum;
  32.     
  33.     if (pb->tcpStream==(StreamPtr)0)
  34.         return tcpNilStream;
  35.     
  36.     pb->csCode=TCPRcvBfrReturn;
  37.     
  38.     return SyncAsync((ParmBlkPtr)pb,async);
  39. }
  40.  
  41. /*
  42.     TCP_Rcv
  43.     
  44.     Retrieves data that has been received on a connection.  Data is copied out of the TCP internal buffers into
  45.     the user's buffer.
  46. */
  47. OSErr TCP_Rcv(TCPiopb* pb,Boolean async){
  48.     
  49.     if (pb==(TCPiopb*)0)
  50.         return tcpNilPB;
  51.     
  52.     if (pb->ioCRefNum==0)
  53.         return tcpNilRefNum;
  54.     
  55.     if (pb->tcpStream==(StreamPtr)0)
  56.         return tcpNilStream;
  57.     
  58.     pb->csCode=TCPRcv;
  59.     
  60.     return SyncAsync((ParmBlkPtr)pb,async);
  61. }
  62.  
  63. /*
  64.     TCP_Close
  65.     
  66.     Signals that the user has no more data to send on the connection.  It does not mean that the connection should
  67.     be broken.  The remote TCP must also issue a close before the connection can be gracefully closed, so a
  68.     connection may remain an arbitrary amount of time after you have issued a TCP_Close.  To break a connection
  69.     without ensuring that all data has been sent and acknowledged, use the TCP_Abort command.
  70. */
  71. OSErr TCP_Close(TCPiopb* pb,Boolean async){
  72.     
  73.     if (pb==(TCPiopb*)0)
  74.         return tcpNilPB;
  75.     
  76.     if (pb->ioCRefNum==0)
  77.         return tcpNilRefNum;
  78.     
  79.     if (pb->tcpStream==(StreamPtr)0)
  80.         return tcpNilStream;
  81.     
  82.     pb->csCode=TCPClose;
  83.     
  84.     return SyncAsync((ParmBlkPtr)pb,async);
  85. }
  86.  
  87. /*
  88.     TCP_Abort
  89.     
  90.     Terminates the connection without attempting to send all outstanding data or to deliver all received data.
  91.     TCP_Abort returns the TCP stream to its initial state.  You are also given a terminate notification.
  92. */
  93. OSErr TCP_Abort(TCPiopb* pb,Boolean async){
  94.     
  95.     if (pb==(TCPiopb*)0)
  96.         return tcpNilPB;
  97.     
  98.     if (pb->ioCRefNum==0)
  99.         return tcpNilRefNum;
  100.     
  101.     if (pb->tcpStream==(StreamPtr)0)
  102.         return tcpNilStream;
  103.     
  104.     pb->csCode=TCPAbort;
  105.     
  106.     return SyncAsync((ParmBlkPtr)pb,async);
  107. }
  108.  
  109. /*
  110.     TCP_Status
  111.     
  112.     Allows you to extract information from TCP regarding a particular connection.
  113. */
  114. OSErr TCP_Status(TCPiopb* pb,Boolean async){
  115.     
  116.     if (pb==(TCPiopb*)0)
  117.         return tcpNilPB;
  118.     
  119.     if (pb->ioCRefNum==0)
  120.         return tcpNilRefNum;
  121.     
  122.     if (pb->tcpStream==(StreamPtr)0)
  123.         return tcpNilStream;
  124.     
  125.     pb->csCode=TCPStatus;
  126.     
  127.     return SyncAsync((ParmBlkPtr)pb,async);
  128. }
  129.  
  130. /*
  131.     TCP_ExtendedStat
  132.     
  133.     Undocumented.  This is not documented in the MacTCP Developers Guide, nor is there anything
  134.     beyond a value for the csCode found in the TCPPB.h file.  It is included here for the completeness
  135.     of the library.
  136. */
  137. OSErr TCP_ExtendedStat(TCPiopb* pb,Boolean async){
  138.     
  139.     if (pb==(TCPiopb*)0)
  140.         return tcpNilPB;
  141.     
  142.     if (pb->ioCRefNum==0)
  143.         return tcpNilRefNum;
  144.     
  145.     if (pb->tcpStream==(StreamPtr)0)
  146.         return tcpNilStream;
  147.     
  148.     pb->csCode=TCPExtendedStat;
  149.     
  150.     return SyncAsync((ParmBlkPtr)pb,async);
  151. }
  152.  
  153. /*
  154.     TCP_Release
  155.     
  156.     Closes a TCP stream.  If there is an open connection on the stream, the connection is first broken as though a
  157.     TCP_Abort command had been issued.
  158. */
  159. OSErr TCP_Release(TCPiopb* pb,Boolean async){
  160.     
  161.     if (pb==(TCPiopb*)0)
  162.         return tcpNilPB;
  163.     
  164.     if (pb->ioCRefNum==0)
  165.         return tcpNilRefNum;
  166.     
  167.     if (pb->tcpStream==(StreamPtr)0)
  168.         return tcpNilStream;
  169.     
  170.     pb->csCode=TCPRelease;
  171.     
  172.     return SyncAsync((ParmBlkPtr)pb,async);
  173. }
  174.  
  175. /*
  176.     TCP_GlobalInfo
  177.     
  178.     Allows access to:
  179.         Parameters that affect the operation of TCP. (*DO NOT MODIFY THESE PARAMETERS!!!)
  180.         Global statistics collected by TCP.
  181. */
  182. OSErr TCP_GlobalInfo(TCPiopb* pb,Boolean async){
  183.     
  184.     if (pb==(TCPiopb*)0)
  185.         return tcpNilPB;
  186.     
  187.     if (pb->ioCRefNum==0)
  188.         return tcpNilRefNum;
  189.     
  190.     if (pb->tcpStream==(StreamPtr)0)
  191.         return tcpNilStream;
  192.     
  193.     pb->csCode=TCPGlobalInfo;
  194.     
  195.     return SyncAsync((ParmBlkPtr)pb,async);
  196. }